package com.piesat.quake.business.device.model.config;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.piesat.quake.business.device.mqtt.anno.IgnoreField;
import com.piesat.quake.business.device.mqtt.anno.LengthField;

import java.io.Serializable;

/**
 * <p>
 *
 * </p>
 *
 * @author ${author}
 * @since 2023-03-13
 */
@TableName("d_passageway")
public class Passageway implements Serializable {

    private static final long serialVersionUID = 1L;

    @IgnoreField
    @TableId(value = "id", type = IdType.INPUT)
    private String id;

    //数据块编号	Byte	1B	当前数据块编号，从1开始编号；
    @TableField(exist = false)
    private Byte number;
    //下一个数据块编号	Byte	1B	指示下一个数据块编号，若为0，表示后续无数据块；
    @TableField(exist = false)
    private Byte nextNumber;
    //数据块长度	Int	4B	包含编号在内的，整个数据块的长度；
    @LengthField
    @TableField(exist = false)
    private int length;
    //通道ID	Byte	1B	通道编号，从1开始编号；
    @TableField("passageway_id")
    private Byte passagewayId;
    //地震事件触发阈值	Float	4B	该通道的实时数据被判定为地震事件触发的阈值；
    @TableField("threshold")
    private Float threshold;
    //实时数据超限阈值	Float	4B	该通道的实时数据被判定为超过正常范围的阈值；
    @TableField("realtime_threshold")
    private Float realtimeThreshold;
    //偏置电压	Double	8B	通过微调传感器偏置电压的数值，使采得的数据更加精确；
    @TableField("bias_voltage")
    private Double biasVoltage;
    //灵敏度	Double	8B	通过微调传感器灵敏度的数值，使采得的数据更加精确；
    @TableField("sensitivity")
    private Double sensitivity;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Byte getNumber() {
        return number;
    }

    public void setNumber(Byte number) {
        this.number = number;
    }

    public Byte getNextNumber() {
        return nextNumber;
    }

    public void setNextNumber(Byte nextNumber) {
        this.nextNumber = nextNumber;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public Byte getPassagewayId() {
        return passagewayId;
    }

    public void setPassagewayId(Byte passagewayId) {
        this.passagewayId = passagewayId;
        this.number = passagewayId;
        if (passagewayId < 6) {
            this.nextNumber = (byte) (passagewayId + 1);
        }else {
            this.nextNumber=0;
        }
    }

    public Float getThreshold() {
        return threshold;
    }

    public void setThreshold(Float threshold) {
        this.threshold = threshold;
    }

    public Float getRealtimeThreshold() {
        return realtimeThreshold;
    }

    public void setRealtimeThreshold(Float realtimeThreshold) {
        this.realtimeThreshold = realtimeThreshold;
    }

    public Double getBiasVoltage() {
        return biasVoltage;
    }

    public void setBiasVoltage(Double biasVoltage) {
        this.biasVoltage = biasVoltage;
    }

    public Double getSensitivity() {
        return sensitivity;
    }

    public void setSensitivity(Double sensitivity) {
        this.sensitivity = sensitivity;
    }

    @Override
    public String toString() {
        return "Passageway{" +
                "id='" + id + '\'' +
                ", number=" + number +
                ", nextNumber=" + nextNumber +
                ", length=" + length +
                ", passagewayId=" + passagewayId +
                ", threshold=" + threshold +
                ", realtimeThreshold=" + realtimeThreshold +
                ", biasVoltage=" + biasVoltage +
                ", sensitivity=" + sensitivity +
                '}';
    }
}
